package cn.johnyu.order.mapper;

import cn.johnyu.order.po.OrderPo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderMapper {
    @Select("select id,user_id as aid,product_id as pid ,pay_amount as amount from orders where id = #{id}")
    OrderPo loadOrder(@Param("id") int id);
    @Select("select id,user_id as aid,product_id as pid ,pay_amount as amount from orders")
    List<OrderPo> findAllOrders();
    @Insert("insert into orders (user_id,product_id,pay_amount) values (#{po.aid},#{po.pid},#{po.amount})")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    int addOrder(@Param("po") OrderPo po);
}
